import os
def ParseData(parsebytes):
  data_len=len(parsebytes)
  i=0
    while(i<data_len-1):
        try:
            frame_code=struct.unpack('<H',parsebytes[i:i+2])[0] #unsigned shortcls
            frame_len=struct.unpack('<I',parsebytes[i:i+4])[0]  #unsigned shortcls
            if 0x06==frame_code:
                print("yes,it is a perfect frame")
        finally:
           # i=i+6     

data_bytes=bytearray()
os.chdir(r'C:\Users\Usmart\Desktop\file_test')
fp=open("index.dat",'rb')
filedata=fp.read()
ParseData(data_bytes)
fp.close()